Imports System.Web
Imports System.Web.SessionState
Imports System.Security.Principal
Imports System.Data.SqlClient
Imports System.Web.Security
Imports renew.FunctionsPublic

Public Class Security

    Shared Sub SetUserName(ByVal strPN_UName As String)

        Dim conDB As SqlConnection = New SqlConnection(GetKey("SQLConnectionString"))
        'Dim connStr As String = ConfigurationManager.ConnectionStrings("MainConnStr").ConnectionString
        Dim cmdSelect As SqlCommand
        Dim dtrRoles As SqlDataReader
        Dim strSql As String

        strSql = "select * from Members where Account_Name =@parPN_UName ;"

        cmdSelect = New SqlCommand(strSql, conDB)
        cmdSelect.Parameters.Add("@parPN_UName", SqlDbType.NVarChar).Value = strPN_UName
        conDB.open()
        'Determine this user's roles
        dtrRoles = cmdSelect.ExecuteReader()

        'assign some information about the user to session
        'Dim objFName As HttpCookie
        'Dim objRoleName As HttpCookie

        Do While dtrRoles.Read()
            HttpContext.Current.Session("PN_Account_Name") = (dtrRoles("Account_Name"))
            HttpContext.Current.Session("PN_Account_ID") = (dtrRoles("Account_ID"))
            HttpContext.Current.Session("Member_ID") = (dtrRoles("Member_ID"))
            HttpContext.Current.Session("FullName") = (dtrRoles("firstname") & " " & dtrRoles("lastname"))
            HttpContext.Current.Session("Affiliate_ID") = (dtrRoles("Affiliate_ID"))
            'objFName = New HttpCookie("FName", dtrRoles("First_Name"))
            'HttpContext.Current.Request.Cookies.Add(objFName)
            'objRoleName = New HttpCookie("Role_Name", dtrRoles("Role_Name"))
            'HttpContext.Current.Request.Cookies.Add(objRoleName)
        Loop

        conDB.close()
    End Sub

End Class